from flask_restful import reqparse, fields


class ClothResource(object):
    fields = {
        'id': fields.Integer,
        'name': fields.String,
        'price': fields.Float,
        'description': fields.String,
        'collar': fields.String,
        'botton': fields.String,
    }

    @classmethod
    def validate_create(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str, required=True, help='Name:str', location=['json'])
        parser.add_argument('price', type=float, required=True, help='Price:float', location=['json'])
        parser.add_argument('description', type=str, help='description:str', location=['json'])
        parser.add_argument('collar', type=str, help='Collar:str', location=['json'])
        parser.add_argument('button', type=str, help='Button:str', location=['json'])
        return parser.parse_args()


class CartResource(object):
    fields = {
        'id': fields.Integer,
        'clothes': fields.Nested(ClothResource.fields),
        'amount': fields.Float,
    }

    @classmethod
    def validate_update(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('cloth_ids', type=int, help='Cloth ID List:str', location=['json'], action='append')
        return parser.parse_args()


class OrderResource(object):
    fields = {
        'id': fields.Integer,
        'clothes': fields.Nested(ClothResource.fields),
        'is'
        'amount': fields.Float,
    }

    @classmethod
    def validate_create(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('cloth_ids', type=int, help='Cloth ID List:str', location=['json'], action='append')
        return parser.parse_args()

    @classmethod
    def validate_update(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('cloth_ids', type=int, help='Cloth ID List:str', location=['json'], action='append')
        return parser.parse_args()

    @classmethod
    def validate_pay(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('money', type=float, required=True, help='Pay Money:float', location=['json'])
        return parser.parse_args()
